#!/usr/bin/env bash
#编译+部署starter

#需要配置如下参数
# 项目路径, 在Execute Shell中配置项目路径, pwd 就可以获得该项目路径
# export PROJ_PATH=这个jenkins任务在部署机器上的路径
### base 函数
killAndStartJar(){
    pid=`ps -ef|grep jenkins-starter|grep java|awk '{print $2}'`
    echo "jenkins-starter Id list :$pid"
    if [ "$pid" = "" ]
    then
      echo "no jenkins-starter pid alive"
    else
      kill -9 $pid
    fi

    echo "启动项目"

    nohup java -jar $PROJ_PATH/target/jenkins-starter.jar > log.file 2>&1 &
    echo "查看项目启动情况："
}

cd $PROJ_PATH

echo "execute mvn clean package"

mvn clean package

sleep 10s

#停jar包
killAndStartJar

ps -ef|grep jenkins-starter



